package com.thoughtworks.bytecode2class;

public class ExceptionInfo {

    private int startPc;
    private int endPc;
    private int handlerPc;
    private int catchType;
    private ClassReader classReader;

    public ExceptionInfo(ClassReader classReader) {
        this.classReader = classReader;
        this.startPc = classReader.forwardChar();
        this.endPc = classReader.forwardChar();
        this.handlerPc = classReader.forwardChar();
        this.catchType = classReader.forwardChar();
    }

    public int getStartPc() {
        return startPc;
    }

    public int getEndPc() {
        return endPc;
    }

    public int getHandlerPc() {
        return handlerPc;
    }

    public String getCatchType() {
        if (catchType == 0) {
            return "any";
        }
        return classReader.getConstantPool().getClassConstant(catchType).getName();
    }
}
